2 # Class representing a Wikipedia article and history.
3 # See design.doc for an overview.
5 # Note: edit user interface and cache support functions have been
6 # moved to separate EditPage and CacheManager classes.
8 include_once( "CacheManager.php" );
11 /* private */ var $mContent, $mContentLoaded;
12 /* private */ var $mUser, $mTimestamp, $mUserText;
13 /* private */ var $mCounter, $mComment, $mCountAdjustment;
14 /* private */ var $mMinorEdit, $mRedirectedFrom;
15 /* private */ var $mTouched, $mFileCache, $mTitle;
16 /* private */ var $mId, $mTable;
18 function Article( &$title ) {
19 $this->mTitle
=& $title;
23 /* private */ function clear()
25 $this->mContentLoaded
= false;
26 $this->mCurID
= $this->mUser
= $this->mCounter
= -1; # Not loaded
27 $this->mRedirectedFrom
= $this->mUserText
=
28 $this->mTimestamp
= $this->mComment
= $this->mFileCache
= "";
29 $this->mCountAdjustment
= 0;
30 $this->mTouched
= "19700101000000";
33 /* static */ function getRevisionText( $row, $prefix = "old_" ) {
34 # Deal with optional compression of archived pages.
35 # This can be done periodically via maintenance/compressOld.php, and
36 # as pages are saved if $wgCompressRevisions is set.
37 $text = $prefix . "text";
38 $flags = $prefix . "flags";
39 if( isset( $row->$flags ) && (false !== strpos( $row->$flags, "gzip" ) ) ) {
40 return gzinflate( $row->$text );
42 if( isset( $row->$text ) ) {
48 /* static */ function compressRevisionText( &$text ) {
49 global $wgCompressRevisions;
50 if( !$wgCompressRevisions ) {
53 if( !function_exists( "gzdeflate" ) ) {
54 wfDebug( "Article::compressRevisionText() -- no zlib support, not compressing\n" );
57 $text = gzdeflate( $text );
61 # Note that getContent/loadContent may follow redirects if
62 # not told otherwise, and so may cause a change to mTitle.
64 # Return the text of this revision
65 function getContent( $noredir = false )
69 # Get variables from query string :P
70 $action = $wgRequest->getText( 'action', 'view' );
71 $section = $wgRequest->getText( 'section' );
73 $fname = "Article::getContent";
74 wfProfileIn( $fname );
76 if ( 0 == $this->getID() ) {
77 if ( "edit" == $action ) {
78 wfProfileOut( $fname );
79 return ""; # was "newarticletext", now moved above the box)
81 wfProfileOut( $fname );
82 return wfMsg( "noarticletext" );
84 $this->loadContent( $noredir );
87 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
88 ( $this->mTitle
->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
89 preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle
->getText()) &&
93 wfProfileOut( $fname );
94 return $this->mContent
. "\n" .wfMsg("anontalkpagetext"); }
99 wfProfileOut( $fname );
103 # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
104 # comments to be stripped as well)
106 $parser=new Parser();
107 $parser->mOutputType
=OT_WIKI
;
108 $striptext=$parser->strip($this->mContent
, $striparray, true);
110 # now that we can be sure that no pseudo-sections are in the source,
111 # split it up by section
114 "/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
116 PREG_SPLIT_DELIM_CAPTURE
);
121 $rv=$secs[$section*2-1] . $secs[$section*2];
124 # reinsert stripped tags
125 $rv=$parser->unstrip($rv,$striparray);
127 wfProfileOut( $fname );
131 wfProfileOut( $fname );
132 return $this->mContent
;
137 # Load the revision (including cur_text) into this object
138 function loadContent( $noredir = false )
140 global $wgOut, $wgMwRedir, $wgRequest;
143 $oldid = $wgRequest->getVal( 'oldid' );
144 $redirect = $wgRequest->getVal( 'redirect' );
146 if ( $this->mContentLoaded
) return;
147 $fname = "Article::loadContent";
149 # Pre-fill content with error message so that if something
150 # fails we'll have something telling us what we intended.
152 $t = $this->mTitle
->getPrefixedText();
153 if ( isset( $oldid ) ) {
154 $oldid = IntVal( $oldid );
155 $t .= ",oldid={$oldid}";
157 if ( isset( $redirect ) ) {
158 $redirect = ($redirect == "no") ?
"no" : "yes";
159 $t .= ",redirect={$redirect}";
161 $this->mContent
= wfMsg( "missingarticle", $t );
163 if ( ! $oldid ) { # Retrieve current version
164 $id = $this->getID();
165 if ( 0 == $id ) return;
168 "cur_text,cur_timestamp,cur_user,cur_counter,cur_restrictions,cur_touched " .
169 "FROM cur WHERE cur_id={$id}";
171 $res = wfQuery( $sql, DB_READ
, $fname );
172 if ( 0 == wfNumRows( $res ) ) {
176 $s = wfFetchObject( $res );
177 # If we got a redirect, follow it (unless we've been told
178 # not to by either the function parameter or the query
179 if ( ( "no" != $redirect ) && ( false == $noredir ) &&
180 ( $wgMwRedir->matchStart( $s->cur_text
) ) ) {
181 if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/",
182 $s->cur_text
, $m ) ) {
183 $rt = Title
::newFromText( $m[1] );
185 # Gotta hand redirects to special pages differently:
186 # Fill the HTTP response "Location" header and ignore
187 # the rest of the page we're on.
189 if ( $rt->getInterwiki() != "" ) {
190 $wgOut->redirect( $rt->getFullURL() ) ;
193 if ( $rt->getNamespace() == Namespace::getSpecial() ) {
194 $wgOut->redirect( $rt->getFullURL() );
197 $rid = $rt->getArticleID();
199 $sql = "SELECT cur_text,cur_timestamp,cur_user," .
200 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
201 $res = wfQuery( $sql, DB_READ
, $fname );
203 if ( 0 != wfNumRows( $res ) ) {
204 $this->mRedirectedFrom
= $this->mTitle
->getPrefixedText();
206 $s = wfFetchObject( $res );
213 $this->mContent
= $s->cur_text
;
214 $this->mUser
= $s->cur_user
;
215 $this->mCounter
= $s->cur_counter
;
216 $this->mTimestamp
= $s->cur_timestamp
;
217 $this->mTouched
= $s->cur_touched
;
218 $this->mTitle
->mRestrictions
= explode( ",", trim( $s->cur_restrictions
) );
219 $this->mTitle
->mRestrictionsLoaded
= true;
220 wfFreeResult( $res );
221 } else { # oldid set, retrieve historical version
222 $sql = "SELECT old_text,old_timestamp,old_user,old_flags FROM old " .
223 "WHERE old_id={$oldid}";
224 $res = wfQuery( $sql, DB_READ
, $fname );
225 if ( 0 == wfNumRows( $res ) ) { return; }
227 $s = wfFetchObject( $res );
228 $this->mContent
= Article
::getRevisionText( $s );
229 $this->mUser
= $s->old_user
;
231 $this->mTimestamp
= $s->old_timestamp
;
232 wfFreeResult( $res );
234 $this->mContentLoaded
= true;
235 return $this->mContent
;
238 # Gets the article text without using so many damn globals
239 # Returns false on error
240 function getContentWithoutUsingSoManyDamnGlobals( $oldid = 0, $noredir = false ) {
243 if ( $this->mContentLoaded
) {
244 return $this->mContent
;
246 $this->mContent
= false;
248 $fname = "Article::loadContent";
250 if ( ! $oldid ) { # Retrieve current version
251 $id = $this->getID();
257 "cur_text,cur_timestamp,cur_user,cur_counter,cur_restrictions,cur_touched " .
258 "FROM cur WHERE cur_id={$id}";
259 $res = wfQuery( $sql, DB_READ
, $fname );
260 if ( 0 == wfNumRows( $res ) ) {
264 $s = wfFetchObject( $res );
265 # If we got a redirect, follow it (unless we've been told
266 # not to by either the function parameter or the query
267 if ( !$noredir && $wgMwRedir->matchStart( $s->cur_text
) ) {
268 if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/",
269 $s->cur_text
, $m ) ) {
270 $rt = Title
::newFromText( $m[1] );
271 if( $rt && $rt->getInterwiki() == "" && $rt->getNamespace() != Namespace::getSpecial() ) {
272 $rid = $rt->getArticleID();
274 $sql = "SELECT cur_text,cur_timestamp,cur_user," .
275 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
276 $res = wfQuery( $sql, DB_READ
, $fname );
278 if ( 0 != wfNumRows( $res ) ) {
279 $this->mRedirectedFrom
= $this->mTitle
->getPrefixedText();
281 $s = wfFetchObject( $res );
288 $this->mContent
= $s->cur_text
;
289 $this->mUser
= $s->cur_user
;
290 $this->mCounter
= $s->cur_counter
;
291 $this->mTimestamp
= $s->cur_timestamp
;
292 $this->mTouched
= $s->cur_touched
;
293 $this->mTitle
->mRestrictions
= explode( ",", trim( $s->cur_restrictions
) );
294 $this->mTitle
->mRestrictionsLoaded
= true;
295 wfFreeResult( $res );
296 } else { # oldid set, retrieve historical version
297 $sql = "SELECT old_text,old_timestamp,old_user,old_flags FROM old " .
298 "WHERE old_id={$oldid}";
299 $res = wfQuery( $sql, DB_READ
, $fname );
300 if ( 0 == wfNumRows( $res ) ) {
304 $s = wfFetchObject( $res );
305 $this->mContent
= Article
::getRevisionText( $s );
306 $this->mUser
= $s->old_user
;
308 $this->mTimestamp
= $s->old_timestamp
;
309 wfFreeResult( $res );
311 $this->mContentLoaded
= true;
312 return $this->mContent
;
316 if( $this->mTitle
) {
317 return $this->mTitle
->getArticleID();
325 if ( -1 == $this->mCounter
) {
326 $id = $this->getID();
327 $this->mCounter
= wfGetSQL( "cur", "cur_counter", "cur_id={$id}" );
329 return $this->mCounter
;
332 # Would the given text make this article a "good" article (i.e.,
333 # suitable for including in the article count)?
335 function isCountable( $text )
337 global $wgUseCommaCount, $wgMwRedir;
339 if ( 0 != $this->mTitle
->getNamespace() ) { return 0; }
340 if ( $wgMwRedir->matchStart( $text ) ) { return 0; }
341 $token = ($wgUseCommaCount ?
"," : "[[" );
342 if ( false === strstr( $text, $token ) ) { return 0; }
346 # Loads everything from cur except cur_text
347 # This isn't necessary for all uses, so it's only done if needed.
349 /* private */ function loadLastEdit()
352 if ( -1 != $this->mUser
) return;
354 $sql = "SELECT cur_user,cur_user_text,cur_timestamp," .
355 "cur_comment,cur_minor_edit FROM cur WHERE " .
356 "cur_id=" . $this->getID();
357 $res = wfQuery( $sql, DB_READ
, "Article::loadLastEdit" );
359 if ( wfNumRows( $res ) > 0 ) {
360 $s = wfFetchObject( $res );
361 $this->mUser
= $s->cur_user
;
362 $this->mUserText
= $s->cur_user_text
;
363 $this->mTimestamp
= $s->cur_timestamp
;
364 $this->mComment
= $s->cur_comment
;
365 $this->mMinorEdit
= $s->cur_minor_edit
;
369 function getTimestamp()
371 $this->loadLastEdit();
372 return $this->mTimestamp
;
377 $this->loadLastEdit();
381 function getUserText()
383 $this->loadLastEdit();
384 return $this->mUserText
;
387 function getComment()
389 $this->loadLastEdit();
390 return $this->mComment
;
393 function getMinorEdit()
395 $this->loadLastEdit();
396 return $this->mMinorEdit
;
399 function getContributors($limit = 0, $offset = 0)
401 $fname = "Article::getContributors";
403 # XXX: this is expensive; cache this info somewhere.
405 $title = $this->mTitle
;
409 $sql = "SELECT old.old_user, old.old_user_text, " .
410 " user.user_real_name, MAX(old.old_timestamp) as timestamp" .
412 " WHERE old.old_user = user.user_id " .
413 " AND old.old_namespace = " . $title->getNamespace() .
414 " AND old.old_title = '" . $title->getDBkey() . "'" .
415 " AND old.old_user != 0 " .
416 " AND old.old_user != " . $this->getUser() .
417 " GROUP BY old.old_user " .
418 " ORDER BY timestamp DESC ";
421 $sql .= " LIMIT $limit";
424 $res = wfQuery($sql, DB_READ
, $fname);
426 while ( $line = wfFetchObject( $res ) ) {
427 $contribs[$line->old_user
] =
428 array($line->old_user_text
, $line->user_real_name
);
431 # Count anonymous users
433 $res = wfQuery("SELECT COUNT(*) AS cnt " .
435 " WHERE old_namespace = " . $title->getNamespace() .
436 " AND old_title = '" . $title->getDBkey() . "'" .
437 " AND old_user = 0 ", DB_READ
, $fname);
439 while ( $line = wfFetchObject( $res ) ) {
440 $contribs[0] = array($line->cnt
, 'Anonymous');
446 # This is the default action of the script: just view the page of
451 global $wgUser, $wgOut, $wgLang, $wgRequest;
452 global $wgLinkCache, $IP, $wgEnableParserCache;
454 $fname = "Article::view";
455 wfProfileIn( $fname );
457 # Get variables from query string :P
458 $oldid = $wgRequest->getVal( 'oldid' );
459 $diff = $wgRequest->getVal( 'diff' );
461 $wgOut->setArticleFlag( true );
462 $wgOut->setRobotpolicy( "index,follow" );
464 # If we got diff and oldid in the query, we want to see a
465 # diff page instead of the article.
467 if ( !is_null( $diff ) ) {
468 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
469 $de = new DifferenceEngine( intval($oldid), intval($diff) );
471 wfProfileOut( $fname );
475 if ( !is_null( $oldid ) and $this->checkTouched() ) {
476 if( $wgOut->checkLastModified( $this->mTouched
) ){
478 } else if ( $this->tryFileCache() ) {
479 # tell wgOut that output is taken care of
481 $this->viewUpdates();
486 $text = $this->getContent(); # May change mTitle
487 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
489 # We're looking at an old revision
491 if ( !empty( $oldid ) ) {
492 $this->setOldSubtitle();
493 $wgOut->setRobotpolicy( "noindex,follow" );
495 if ( "" != $this->mRedirectedFrom
) {
496 $sk = $wgUser->getSkin();
497 $redir = $sk->makeKnownLink( $this->mRedirectedFrom
, "",
499 $s = wfMsg( "redirectedfrom", $redir );
500 $wgOut->setSubtitle( $s );
503 $wgLinkCache->preFill( $this->mTitle
);
505 if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 ){
506 $wgOut->addWikiText( $text, true, $this );
508 $wgOut->addWikiText( $text );
511 # Add link titles as META keywords
512 $wgOut->addMetaTags() ;
514 $this->viewUpdates();
515 wfProfileOut( $fname );
518 # Theoretically we could defer these whole insert and update
519 # functions for after display, but that's taking a big leap
520 # of faith, and we want to be able to report database
521 # errors at some point.
523 /* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
525 global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir;
526 global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
528 $fname = "Article::insertNewArticle";
530 $this->mCountAdjustment
= $this->isCountable( $text );
532 $ns = $this->mTitle
->getNamespace();
533 $ttl = $this->mTitle
->getDBkey();
534 $text = $this->preSaveTransform( $text );
535 if ( $wgMwRedir->matchStart( $text ) ) { $redir = 1; }
538 $now = wfTimestampNow();
539 $won = wfInvertTimestamp( $now );
541 $rand = number_format( mt_rand() / mt_getrandmax(), 12, ".", "" );
542 $isminor = ( $isminor && $wgUser->getID() ) ?
1 : 0;
543 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
544 "cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
545 "cur_restrictions,cur_user_text,cur_is_redirect," .
546 "cur_is_new,cur_random,cur_touched,inverse_timestamp) VALUES ({$ns},'" . wfStrencode( $ttl ) . "', '" .
547 wfStrencode( $text ) . "', '" .
548 wfStrencode( $summary ) . "', '" .
549 $wgUser->getID() . "', '{$now}', " .
550 $isminor . ", 0, '', '" .
551 wfStrencode( $wgUser->getName() ) . "', $redir, 1, $rand, '{$now}', '{$won}')";
552 $res = wfQuery( $sql, DB_WRITE
, $fname );
554 $newid = wfInsertId();
555 $this->mTitle
->resetArticleID( $newid );
557 Article
::onArticleCreate( $this->mTitle
);
558 RecentChange
::notifyNew( $now, $this->mTitle
, $isminor, $wgUser, $summary );
561 if(!$this->mTitle
->userIsWatching()) $this->watch();
563 if ( $this->mTitle
->userIsWatching() ) {
568 # The talk page isn't in the regular link tables, so we need to update manually:
569 $talkns = $ns ^
1; # talk -> normal; normal -> talk
570 $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'";
571 wfQuery( $sql, DB_WRITE
);
573 # standard deferred updates
574 $this->editUpdates( $text );
576 $this->showArticle( $text, wfMsg( "newarticle" ) );
580 /* Side effects: loads last edit */
581 function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = ""){
582 $this->loadLastEdit();
583 $oldtext = $this->getContent();
584 if ($section != "") {
585 if($section=="new") {
586 if($summary) $subject="== {$summary} ==\n\n";
587 $text=$oldtext."\n\n".$subject.$text;
590 # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
591 # comments to be stripped as well)
593 $parser=new Parser();
594 $parser->mOutputType
=OT_WIKI
;
595 $oldtext=$parser->strip($oldtext, $striparray, true);
597 # now that we can be sure that no pseudo-sections are in the source,
599 $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
600 $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE
);
601 $secs[$section*2]=$text."\n\n"; // replace with edited
602 if($section) { $secs[$section*2-1]=""; } // erase old headline
603 $text=join("",$secs);
605 # reinsert the stuff that we stripped out earlier
606 $text=$parser->unstrip($text,$striparray,true);
612 function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false )
614 global $wgOut, $wgUser, $wgLinkCache;
615 global $wgDBtransactions, $wgMwRedir;
616 global $wgUseSquid, $wgInternalServer;
617 $fname = "Article::updateArticle";
619 if ( $this->mMinorEdit
) { $me1 = 1; } else { $me1 = 0; }
620 if ( $minor && $wgUser->getID() ) { $me2 = 1; } else { $me2 = 0; }
621 if ( preg_match( "/^((" . $wgMwRedir->getBaseRegex() . ")[^\\n]+)/i", $text, $m ) ) {
623 $text = $m[1] . "\n"; # Remove all content but redirect
627 $text = $this->preSaveTransform( $text );
629 # Update article, but only if changed.
631 if( $wgDBtransactions ) {
633 wfQuery( $sql, DB_WRITE
);
635 $oldtext = $this->getContent( true );
637 if ( 0 != strcmp( $text, $oldtext ) ) {
638 $this->mCountAdjustment
= $this->isCountable( $text )
639 - $this->isCountable( $oldtext );
641 $now = wfTimestampNow();
642 $won = wfInvertTimestamp( $now );
643 $sql = "UPDATE cur SET cur_text='" . wfStrencode( $text ) .
644 "',cur_comment='" . wfStrencode( $summary ) .
645 "',cur_minor_edit={$me2}, cur_user=" . $wgUser->getID() .
646 ",cur_timestamp='{$now}',cur_user_text='" .
647 wfStrencode( $wgUser->getName() ) .
648 "',cur_is_redirect={$redir}, cur_is_new=0, cur_touched='{$now}', inverse_timestamp='{$won}' " .
649 "WHERE cur_id=" . $this->getID() .
650 " AND cur_timestamp='" . $this->getTimestamp() . "'";
651 $res = wfQuery( $sql, DB_WRITE
, $fname );
653 if( wfAffectedRows() == 0 ) {
654 /* Belated edit conflict! Run away!! */
658 # This overwrites $oldtext if revision compression is on
659 $flags = Article
::compressRevisionText( $oldtext );
661 $sql = "INSERT INTO old (old_namespace,old_title,old_text," .
662 "old_comment,old_user,old_user_text,old_timestamp," .
663 "old_minor_edit,inverse_timestamp,old_flags) VALUES (" .
664 $this->mTitle
->getNamespace() . ", '" .
665 wfStrencode( $this->mTitle
->getDBkey() ) . "', '" .
666 wfStrencode( $oldtext ) . "', '" .
667 wfStrencode( $this->getComment() ) . "', " .
668 $this->getUser() . ", '" .
669 wfStrencode( $this->getUserText() ) . "', '" .
670 $this->getTimestamp() . "', " . $me1 . ", '" .
671 wfInvertTimestamp( $this->getTimestamp() ) . "','$flags')";
672 $res = wfQuery( $sql, DB_WRITE
, $fname );
673 $oldid = wfInsertID( $res );
675 $bot = (int)($wgUser->isBot() ||
$forceBot);
676 RecentChange
::notifyEdit( $now, $this->mTitle
, $me2, $wgUser, $summary,
677 $oldid, $this->getTimestamp(), $bot );
678 Article
::onArticleEdit( $this->mTitle
);
681 if( $wgDBtransactions ) {
683 wfQuery( $sql, DB_WRITE
);
687 if (!$this->mTitle
->userIsWatching()) $this->watch();
689 if ( $this->mTitle
->userIsWatching() ) {
693 # standard deferred updates
694 $this->editUpdates( $text );
699 # Purge all articles linking here
700 if ( $this->mTitle
->getNamespace() == NS_TEMPLATE
) {
701 $titles = $this->mTitle
->getLinksTo();
702 Title
::touchArray( $titles );
704 foreach ( $titles as $title ) {
705 $urls[] = $title->getInternalURL();
712 $urls = array_merge( $urls, $this->mTitle
->getSquidURLs() );
713 $u = new SquidUpdate( $urls );
717 $this->showArticle( $text, wfMsg( "updated" ) );
721 # After we've either updated or inserted the article, update
722 # the link tables and redirect to the new page.
724 function showArticle( $text, $subtitle )
726 global $wgOut, $wgUser, $wgLinkCache;
729 $wgLinkCache = new LinkCache();
731 # Get old version of link table to allow incremental link updates
732 $wgLinkCache->preFill( $this->mTitle
);
733 $wgLinkCache->clear();
735 # Now update the link cache by parsing the text
736 $wgOut = new OutputPage();
737 $wgOut->addWikiText( $text );
739 if( $wgMwRedir->matchStart( $text ) )
743 $wgOut->redirect( $this->mTitle
->getFullURL( $r ) );
746 # Add this page to my watchlist
748 function watch( $add = true )
750 global $wgUser, $wgOut, $wgLang;
751 global $wgDeferredUpdateList;
753 if ( 0 == $wgUser->getID() ) {
754 $wgOut->errorpage( "watchnologin", "watchnologintext" );
757 if ( wfReadOnly() ) {
758 $wgOut->readOnlyPage();
762 $wgUser->addWatch( $this->mTitle
);
764 $wgUser->removeWatch( $this->mTitle
);
766 $wgOut->setPagetitle( wfMsg( $add ?
"addedwatch" : "removedwatch" ) );
767 $wgOut->setRobotpolicy( "noindex,follow" );
769 $sk = $wgUser->getSkin() ;
770 $link = $this->mTitle
->getPrefixedText();
773 $text = wfMsg( "addedwatchtext", $link );
775 $text = wfMsg( "removedwatchtext", $link );
776 $wgOut->addWikiText( $text );
778 $up = new UserUpdate();
779 array_push( $wgDeferredUpdateList, $up );
781 $wgOut->returnToMain( false );
786 $this->watch( false );
789 function protect( $limit = "sysop" )
791 global $wgUser, $wgOut, $wgRequest;
793 if ( ! $wgUser->isSysop() ) {
794 $wgOut->sysopRequired();
797 if ( wfReadOnly() ) {
798 $wgOut->readOnlyPage();
801 $id = $this->mTitle
->getArticleID();
803 $wgOut->fatalError( wfMsg( "badarticleerror" ) );
807 $confirm = $wgRequest->getBool( 'wpConfirmProtect' ) && $wgRequest->wasPosted();
808 $reason = $wgRequest->getText( 'wpReasonProtect' );
812 $sql = "UPDATE cur SET cur_touched='" . wfTimestampNow() . "'," .
813 "cur_restrictions='{$limit}' WHERE cur_id={$id}";
814 wfQuery( $sql, DB_WRITE
, "Article::protect" );
816 $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) );
817 if ( $limit === "" ) {
818 $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle
->getPrefixedText() ), $reason );
820 $log->addEntry( wfMsg( "protectedarticle", $this->mTitle
->getPrefixedText() ), $reason );
822 $wgOut->redirect( $this->mTitle
->getFullURL() );
825 $reason = htmlspecialchars( wfMsg( "protectreason" ) );
826 return $this->confirmProtect( "", $reason, $limit );
830 # Output protection confirmation dialog
831 function confirmProtect( $par, $reason, $limit = "sysop" )
835 wfDebug( "Article::confirmProtect\n" );
837 $sub = htmlspecialchars( $this->mTitle
->getPrefixedText() );
838 $wgOut->setRobotpolicy( "noindex,nofollow" );
843 if ( $limit === "" ) {
844 $wgOut->setSubtitle( wfMsg( "unprotectsub", $sub ) );
845 $wgOut->addWikiText( wfMsg( "confirmunprotecttext" ) );
846 $check = htmlspecialchars( wfMsg( "confirmunprotect" ) );
847 $protcom = htmlspecialchars( wfMsg( "unprotectcomment" ) );
848 $formaction = $this->mTitle
->escapeLocalURL( "action=unprotect" . $par );
850 $wgOut->setSubtitle( wfMsg( "protectsub", $sub ) );
851 $wgOut->addWikiText( wfMsg( "confirmprotecttext" ) );
852 $check = htmlspecialchars( wfMsg( "confirmprotect" ) );
853 $protcom = htmlspecialchars( wfMsg( "protectcomment" ) );
854 $formaction = $this->mTitle
->escapeLocalURL( "action=protect" . $par );
857 $confirm = htmlspecialchars( wfMsg( "confirm" ) );
860 <form id='protectconfirm' method='post' action=\"{$formaction}\">
864 <label for='wpReasonProtect'>{$protcom}:</label>
867 <input type='text' size='60' name='wpReasonProtect' id='wpReasonProtect' value=\"" . htmlspecialchars( $reason ) . "\" />
875 <input type='checkbox' name='wpConfirmProtect' value='1' id='wpConfirmProtect' />
878 <label for='wpConfirmProtect'>{$check}</label>
884 <input type='submit' name='wpConfirmProtectB' value=\"{$confirm}\" />
890 $wgOut->returnToMain( false );
895 return $this->protect( "" );
898 # UI entry point for page deletion
901 global $wgUser, $wgOut, $wgMessageCache, $wgRequest;
902 $fname = "Article::delete";
903 $confirm = $wgRequest->getBool( 'wpConfirm' ) && $wgRequest->wasPosted();
904 $reason = $wgRequest->getText( 'wpReason' );
906 # This code desperately needs to be totally rewritten
909 if ( ( ! $wgUser->isSysop() ) ) {
910 $wgOut->sysopRequired();
913 if ( wfReadOnly() ) {
914 $wgOut->readOnlyPage();
918 # Better double-check that it hasn't been deleted yet!
919 $wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
920 if ( ( "" == trim( $this->mTitle
->getText() ) )
921 or ( $this->mTitle
->getArticleId() == 0 ) ) {
922 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
927 $this->doDelete( $reason );
931 # determine whether this page has earlier revisions
932 # and insert a warning if it does
933 # we select the text because it might be useful below
934 $ns = $this->mTitle
->getNamespace();
935 $title = $this->mTitle
->getDBkey();
936 $etitle = wfStrencode( $title );
937 $sql = "SELECT old_text,old_flags FROM old WHERE old_namespace=$ns and old_title='$etitle' ORDER BY inverse_timestamp LIMIT 1";
938 $res = wfQuery( $sql, DB_READ
, $fname );
939 if( ($old=wfFetchObject($res)) && !$confirm ) {
940 $skin=$wgUser->getSkin();
941 $wgOut->addHTML("<b>".wfMsg("historywarning"));
942 $wgOut->addHTML( $skin->historyLink() ."</b>");
945 $sql="SELECT cur_text FROM cur WHERE cur_namespace=$ns and cur_title='$etitle'";
946 $res=wfQuery($sql, DB_READ
, $fname);
947 if( ($s=wfFetchObject($res))) {
949 # if this is a mini-text, we can paste part of it into the deletion reason
951 #if this is empty, an earlier revision may contain "useful" text
953 if($s->cur_text
!="") {
957 $text = Article
::getRevisionText( $old );
963 $length=strlen($text);
965 # this should not happen, since it is not possible to store an empty, new
966 # page. Let's insert a standard text in case it does, though
967 if($length == 0 && $reason === "") {
968 $reason = wfMsg("exblank");
971 if($length < 500 && $reason === "") {
973 # comment field=255, let's grep the first 150 to have some user
975 $text=substr($text,0,150);
976 # let's strip out newlines and HTML tags
977 $text=preg_replace("/\"/","'",$text);
978 $text=preg_replace("/\</","<",$text);
979 $text=preg_replace("/\>/",">",$text);
980 $text=preg_replace("/[\n\r]/","",$text);
982 $reason=wfMsg("excontent"). " '".$text;
984 $reason=wfMsg("exbeforeblank") . " '".$text;
986 if($length>150) { $reason .= "..."; } # we've only pasted part of the text
991 return $this->confirmDelete( "", $reason );
994 # Output deletion confirmation dialog
995 function confirmDelete( $par, $reason )
999 wfDebug( "Article::confirmDelete\n" );
1001 $sub = htmlspecialchars( $this->mTitle
->getPrefixedText() );
1002 $wgOut->setSubtitle( wfMsg( "deletesub", $sub ) );
1003 $wgOut->setRobotpolicy( "noindex,nofollow" );
1004 $wgOut->addWikiText( wfMsg( "confirmdeletetext" ) );
1006 $formaction = $this->mTitle
->escapeLocalURL( "action=delete" . $par );
1008 $confirm = htmlspecialchars( wfMsg( "confirm" ) );
1009 $check = htmlspecialchars( wfMsg( "confirmcheck" ) );
1010 $delcom = htmlspecialchars( wfMsg( "deletecomment" ) );
1013 <form id='deleteconfirm' method='post' action=\"{$formaction}\">
1017 <label for='wpReason'>{$delcom}:</label>
1020 <input type='text' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" />
1028 <input type='checkbox' name='wpConfirm' value='1' id='wpConfirm' />
1031 <label for='wpConfirm'>{$check}</label>
1037 <input type='submit' name='wpConfirmB' value=\"{$confirm}\" />
1043 $wgOut->returnToMain( false );
1046 # Perform a deletion and output success or failure messages
1047 function doDelete( $reason )
1049 global $wgOut, $wgUser, $wgLang;
1050 $fname = "Article::doDelete";
1051 wfDebug( "$fname\n" );
1053 if ( $this->doDeleteArticle( $reason ) ) {
1054 $deleted = $this->mTitle
->getPrefixedText();
1056 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
1057 $wgOut->setRobotpolicy( "noindex,nofollow" );
1059 $sk = $wgUser->getSkin();
1060 $loglink = $sk->makeKnownLink( $wgLang->getNsText(
1061 Namespace::getWikipedia() ) .
1062 ":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
1064 $text = wfMsg( "deletedtext", $deleted, $loglink );
1066 $wgOut->addHTML( "<p>" . $text . "</p>\n" );
1067 $wgOut->returnToMain( false );
1069 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
1073 # Back-end article deletion
1074 # Deletes the article with database consistency, writes logs, purges caches
1076 function doDeleteArticle( $reason )
1078 global $wgUser, $wgLang;
1079 global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
1081 $fname = "Article::doDeleteArticle";
1082 wfDebug( "$fname\n" );
1084 $ns = $this->mTitle
->getNamespace();
1085 $t = wfStrencode( $this->mTitle
->getDBkey() );
1086 $id = $this->mTitle
->getArticleID();
1088 if ( "" == $t ||
$id == 0 ) {
1092 $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ) );
1093 array_push( $wgDeferredUpdateList, $u );
1095 $linksTo = $this->mTitle
->getLinksTo();
1098 if ( $wgUseSquid ) {
1100 $this->mTitle
->getInternalURL(),
1101 $this->mTitle
->getInternalURL( "history" )
1103 foreach ( $linksTo as $linkTo ) {
1104 $urls[] = $linkTo->getInternalURL();
1107 $u = new SquidUpdate( $urls );
1108 array_push( $wgDeferredUpdateList, $u );
1112 # Client and file cache invalidation
1113 Title
::touchArray( $linksTo );
1115 # Move article and history to the "archive" table
1116 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
1117 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
1118 "ar_flags) SELECT cur_namespace,cur_title,cur_text,cur_comment," .
1119 "cur_user,cur_user_text,cur_timestamp,cur_minor_edit,0 FROM cur " .
1120 "WHERE cur_namespace={$ns} AND cur_title='{$t}'";
1121 wfQuery( $sql, DB_WRITE
, $fname );
1123 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
1124 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
1125 "ar_flags) SELECT old_namespace,old_title,old_text,old_comment," .
1126 "old_user,old_user_text,old_timestamp,old_minor_edit,old_flags " .
1127 "FROM old WHERE old_namespace={$ns} AND old_title='{$t}'";
1128 wfQuery( $sql, DB_WRITE
, $fname );
1130 # Now that it's safely backed up, delete it
1132 $sql = "DELETE FROM cur WHERE cur_namespace={$ns} AND " .
1134 wfQuery( $sql, DB_WRITE
, $fname );
1136 $sql = "DELETE FROM old WHERE old_namespace={$ns} AND " .
1138 wfQuery( $sql, DB_WRITE
, $fname );
1140 $sql = "DELETE FROM recentchanges WHERE rc_namespace={$ns} AND " .
1142 wfQuery( $sql, DB_WRITE
, $fname );
1144 # Finally, clean up the link tables
1145 $t = wfStrencode( $this->mTitle
->getPrefixedDBkey() );
1147 Article
::onArticleDelete( $this->mTitle
);
1149 $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
1152 foreach ( $linksTo as $titleObj ) {
1153 if ( ! $first ) { $sql .= ","; }
1155 # Get article ID. Efficient because it was loaded into the cache by getLinksTo().
1156 $linkID = $titleObj->getArticleID();
1157 $sql .= "({$linkID},'{$t}')";
1160 wfQuery( $sql, DB_WRITE
, $fname );
1163 $sql = "DELETE FROM links WHERE l_to={$id}";
1164 wfQuery( $sql, DB_WRITE
, $fname );
1166 $sql = "DELETE FROM links WHERE l_from={$id}";
1167 wfQuery( $sql, DB_WRITE
, $fname );
1169 $sql = "DELETE FROM imagelinks WHERE il_from={$id}";
1170 wfQuery( $sql, DB_WRITE
, $fname );
1172 $sql = "DELETE FROM brokenlinks WHERE bl_from={$id}";
1173 wfQuery( $sql, DB_WRITE
, $fname );
1175 $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
1176 $art = $this->mTitle
->getPrefixedText();
1177 $log->addEntry( wfMsg( "deletedarticle", $art ), $reason );
1179 # Clear the cached article id so the interface doesn't act like we exist
1180 $this->mTitle
->resetArticleID( 0 );
1181 $this->mTitle
->mArticleID
= 0;
1187 global $wgUser, $wgLang, $wgOut, $wgRequest;
1189 if ( ! $wgUser->isSysop() ) {
1190 $wgOut->sysopRequired();
1193 if ( wfReadOnly() ) {
1194 $wgOut->readOnlyPage( $this->getContent() );
1198 # Enhanced rollback, marks edits rc_bot=1
1199 $bot = $wgRequest->getBool( 'bot' );
1201 # Replace all this user's current edits with the next one down
1202 $tt = wfStrencode( $this->mTitle
->getDBKey() );
1203 $n = $this->mTitle
->getNamespace();
1205 # Get the last editor
1206 $sql = "SELECT cur_id,cur_user,cur_user_text,cur_comment FROM cur WHERE cur_title='{$tt}' AND cur_namespace={$n}";
1207 $res = wfQuery( $sql, DB_READ
);
1208 if( ($x = wfNumRows( $res )) != 1 ) {
1210 $wgOut->addHTML( wfMsg( "notanarticle" ) );
1213 $s = wfFetchObject( $res );
1214 $ut = wfStrencode( $s->cur_user_text
);
1215 $uid = $s->cur_user
;
1218 $from = str_replace( '_', ' ', $wgRequest->getVal( "from" ) );
1219 if( $from != $s->cur_user_text
) {
1220 $wgOut->setPageTitle(wfmsg("rollbackfailed"));
1221 $wgOut->addWikiText( wfMsg( "alreadyrolled",
1222 htmlspecialchars( $this->mTitle
->getPrefixedText()),
1223 htmlspecialchars( $from ),
1224 htmlspecialchars( $s->cur_user_text
) ) );
1225 if($s->cur_comment
!= "") {
1227 wfMsg("editcomment",
1228 htmlspecialchars( $s->cur_comment
) ) );
1233 # Get the last edit not by this guy
1234 $sql = "SELECT old_text,old_user,old_user_text,old_timestamp,old_flags
1235 FROM old USE INDEX (name_title_timestamp)
1236 WHERE old_namespace={$n} AND old_title='{$tt}'
1237 AND (old_user <> {$uid} OR old_user_text <> '{$ut}')
1238 ORDER BY inverse_timestamp LIMIT 1";
1239 $res = wfQuery( $sql, DB_READ
);
1240 if( wfNumRows( $res ) != 1 ) {
1242 $wgOut->setPageTitle(wfMsg("rollbackfailed"));
1243 $wgOut->addHTML( wfMsg( "cantrollback" ) );
1246 $s = wfFetchObject( $res );
1249 # Mark all reverted edits as bot
1250 $sql = "UPDATE recentchanges SET rc_bot=1 WHERE
1251 rc_cur_id=$pid AND rc_user=$uid AND rc_timestamp > '{$s->old_timestamp}'";
1252 wfQuery( $sql, DB_WRITE
, $fname );
1256 $newcomment = wfMsg( "revertpage", $s->old_user_text
, $from );
1257 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
1258 $wgOut->setRobotpolicy( "noindex,nofollow" );
1259 $wgOut->addHTML( "<h2>" . $newcomment . "</h2>\n<hr />\n" );
1260 $this->updateArticle( Article
::getRevisionText( $s ), $newcomment, 1, $this->mTitle
->userIsWatching(), $bot );
1261 Article
::onArticleEdit( $this->mTitle
);
1262 $wgOut->returnToMain( false );
1266 # Do standard deferred updates after page view
1268 /* private */ function viewUpdates()
1270 global $wgDeferredUpdateList;
1271 if ( 0 != $this->getID() ) {
1272 global $wgDisableCounters;
1273 if( !$wgDisableCounters ) {
1274 Article
::incViewCount( $this->getID() );
1275 $u = new SiteStatsUpdate( 1, 0, 0 );
1276 array_push( $wgDeferredUpdateList, $u );
1278 $u = new UserTalkUpdate( 0, $this->mTitle
->getNamespace(),
1279 $this->mTitle
->getDBkey() );
1280 array_push( $wgDeferredUpdateList, $u );
1284 # Do standard deferred updates after page edit.
1285 # Every 1000th edit, prune the recent changes table.
1287 /* private */ function editUpdates( $text )
1289 global $wgDeferredUpdateList, $wgDBname, $wgMemc;
1290 global $wgMessageCache;
1293 if ( 0 == mt_rand( 0, 999 ) ) {
1294 $cutoff = wfUnix2Timestamp( time() - ( 7 * 86400 ) );
1295 $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$cutoff}'";
1296 wfQuery( $sql, DB_WRITE
);
1298 $id = $this->getID();
1299 $title = $this->mTitle
->getPrefixedDBkey();
1300 $shortTitle = $this->mTitle
->getDBkey();
1302 $adj = $this->mCountAdjustment
;
1305 $u = new LinksUpdate( $id, $title );
1306 array_push( $wgDeferredUpdateList, $u );
1307 $u = new SiteStatsUpdate( 0, 1, $adj );
1308 array_push( $wgDeferredUpdateList, $u );
1309 $u = new SearchUpdate( $id, $title, $text );
1310 array_push( $wgDeferredUpdateList, $u );
1312 $u = new UserTalkUpdate( 1, $this->mTitle
->getNamespace(), $shortTitle );
1313 array_push( $wgDeferredUpdateList, $u );
1315 if ( $this->mTitle
->getNamespace() == NS_MEDIAWIKI
) {
1316 $wgMessageCache->replace( $shortTitle, $text );
1321 /* private */ function setOldSubtitle()
1323 global $wgLang, $wgOut;
1325 $td = $wgLang->timeanddate( $this->mTimestamp
, true );
1326 $r = wfMsg( "revisionasof", $td );
1327 $wgOut->setSubtitle( "({$r})" );
1330 # This function is called right before saving the wikitext,
1331 # so we can do things like signatures and links-in-context.
1333 function preSaveTransform( $text )
1335 global $wgParser, $wgUser;
1336 return $wgParser->preSaveTransform( $text, $this->mTitle
, $wgUser, ParserOptions
::newFromUser( $wgUser ) );
1339 /* Caching functions */
1341 # checkLastModified returns true if it has taken care of all
1342 # output to the client that is necessary for this request.
1343 # (that is, it has sent a cached version of the page)
1344 function tryFileCache() {
1345 static $called = false;
1347 wfDebug( " tryFileCache() -- called twice!?\n" );
1351 if($this->isFileCacheable()) {
1352 $touched = $this->mTouched
;
1353 if( $this->mTitle
->getPrefixedDBkey() == wfMsg( "mainpage" ) ) {
1354 # Expire the main page quicker
1355 $expire = wfUnix2Timestamp( time() - 3600 );
1356 $touched = max( $expire, $touched );
1358 $cache = new CacheManager( $this->mTitle
);
1359 if($cache->isFileCacheGood( $touched )) {
1361 wfDebug( " tryFileCache() - about to load\n" );
1362 $cache->loadFromFileCache();
1365 wfDebug( " tryFileCache() - starting buffer\n" );
1366 ob_start( array(&$cache, 'saveToFileCache' ) );
1369 wfDebug( " tryFileCache() - not cacheable\n" );
1373 function isFileCacheable() {
1374 global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest;
1375 extract( $wgRequest->getValues( 'action', 'oldid', 'diff', 'redirect', 'printable' ) );
1377 return $wgUseFileCache
1378 and (!$wgShowIPinHeader)
1379 and ($this->getID() != 0)
1380 and ($wgUser->getId() == 0)
1381 and (!$wgUser->getNewtalk())
1382 and ($this->mTitle
->getNamespace() != Namespace::getSpecial())
1383 and ($action == "view")
1384 and (!isset($oldid))
1386 and (!isset($redirect))
1387 and (!isset($printable))
1388 and (!$this->mRedirectedFrom
);
1391 function checkTouched() {
1392 $id = $this->getID();
1393 $sql = "SELECT cur_touched,cur_is_redirect FROM cur WHERE cur_id=$id";
1394 $res = wfQuery( $sql, DB_READ
, "Article::checkTouched" );
1395 if( $s = wfFetchObject( $res ) ) {
1396 $this->mTouched
= $s->cur_touched
;
1397 return !$s->cur_is_redirect
;
1403 /* static */ function incViewCount( $id )
1405 $id = intval( $id );
1406 global $wgHitcounterUpdateFreq;
1408 if( $wgHitcounterUpdateFreq <= 1 ){ //
1409 wfQuery("UPDATE cur SET cur_counter = cur_counter + 1 " .
1410 "WHERE cur_id = $id", DB_WRITE
);
1414 # Not important enough to warrant an error page in case of failure
1415 $oldignore = wfIgnoreSQLErrors( true );
1417 wfQuery("INSERT INTO hitcounter (hc_id) VALUES ({$id})", DB_WRITE
);
1419 $checkfreq = intval( $wgHitcounterUpdateFreq/25 +
1 );
1420 if( (rand() %
$checkfreq != 0) or (wfLastErrno() != 0) ){
1421 # Most of the time (or on SQL errors), skip row count check
1422 wfIgnoreSQLErrors( $oldignore );
1426 $res = wfQuery("SELECT COUNT(*) as n FROM hitcounter", DB_WRITE
);
1427 $row = wfFetchObject( $res );
1428 $rown = intval( $row->n
);
1429 if( $rown >= $wgHitcounterUpdateFreq ){
1430 wfProfileIn( "Article::incViewCount-collect" );
1431 $old_user_abort = ignore_user_abort( true );
1433 wfQuery("LOCK TABLES hitcounter WRITE", DB_WRITE
);
1434 wfQuery("CREATE TEMPORARY TABLE acchits TYPE=HEAP ".
1435 "SELECT hc_id,COUNT(*) AS hc_n FROM hitcounter ".
1436 "GROUP BY hc_id", DB_WRITE
);
1437 wfQuery("DELETE FROM hitcounter", DB_WRITE
);
1438 wfQuery("UNLOCK TABLES", DB_WRITE
);
1439 wfQuery("UPDATE cur,acchits SET cur_counter=cur_counter + hc_n ".
1440 "WHERE cur_id = hc_id", DB_WRITE
);
1441 wfQuery("DROP TABLE acchits", DB_WRITE
);
1443 ignore_user_abort( $old_user_abort );
1444 wfProfileOut( "Article::incViewCount-collect" );
1446 wfIgnoreSQLErrors( $oldignore );
1449 # The onArticle*() functions are supposed to be a kind of hooks
1450 # which should be called whenever any of the specified actions
1453 # This is a good place to put code to clear caches, for instance.
1455 # This is called on page move and undelete, as well as edit
1456 /* static */ function onArticleCreate($title_obj){
1457 global $wgEnablePersistentLC, $wgEnableParserCache, $wgUseSquid, $wgDeferredUpdateList;
1459 $titles = $title_obj->getBrokenLinksTo();
1462 if ( $wgUseSquid ) {
1463 $urls = $title_obj->getSquidURLs();
1464 foreach ( $titles as $linkTitle ) {
1465 $urls[] = $linkTitle->getInternalURL();
1467 $u = new SquidUpdate( $urls );
1468 array_push( $wgDeferredUpdateList, $u );
1471 # Clear persistent link cache
1472 if ( $wgEnablePersistentLC ) {
1473 LinkCache
::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
1476 # Clear parser cache (not really used)
1477 if ( $wgEnableParserCache ) {
1478 OutputPage
::parsercacheClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
1482 /* static */ function onArticleDelete($title_obj){
1483 global $wgEnablePersistentLC, $wgEnableParserCache;
1484 if ( $wgEnablePersistentLC ) {
1485 LinkCache
::linksccClearLinksTo( $title_obj->getArticleID() );
1487 if ( $wgEnableParserCache ) {
1488 OutputPage
::parsercacheClearLinksTo( $title_obj->getArticleID() );
1492 /* static */ function onArticleEdit($title_obj){
1493 global $wgEnablePersistentLC, $wgEnableParserCache;
1494 if ( $wgEnablePersistentLC ) {
1495 LinkCache
::linksccClearPage( $title_obj->getArticleID() );
1497 if ( $wgEnableParserCache ) {
1498 OutputPage
::parsercacheClearPage( $title_obj->getArticleID(), $title_obj->getNamespace() );